/*
 * @ClassName router_test.dart
 * @Description 路由跳转测试
 * @Author SuPeiSen
 * @Date 2020/7/22 12:18
 */

import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:flutter_su/animation/page_animation/ripple_router.dart';
import 'package:flutter_su/common/application.dart';
import 'package:flutter_su/common/fun.dart';
import 'package:flutter_su/pages/test/common_widget.dart';
import 'package:flutter_su/router/test_router.dart';

class RouterTest extends StatefulWidget {
  @override
  _RouterTestState createState() => _RouterTestState();
}

class _RouterTestState extends State<RouterTest> with CommonTestWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("路由动画跳转"),
      ),
      body: _body(),
    );
  }

//  void _(){
//    SingleChildRenderObjectWidget();
//    MultiChildRenderObjectWidget();
//    StatefulElement();
//    StatelessElement();
//    RenderObjectElement();
//  }

  Widget _body() {
    return Container(
      width: double.infinity,
      child: SingleChildScrollView(
        child: Column(
          children: <Widget>[
            _routerTest(),
          ],
        ),
      ),
    );
  }

  Widget _routerTest() {
    return Column(
      children: <Widget>[
        title("路由动画测试"),
        _fluro(),
        title("自定义路由动画"),
        _my(),
      ],
    );
  }

  Widget _fluro() {
    return Wrap(
      spacing: 10,
      children: <Widget>[
        RaisedButton(
          child: Text("cupertino"),
          onPressed: () {
            Application.router.navigateTo(
              context,
              TestRouter.ROUTER_SECOND_TEST + "?title=cupertino",
              transition: TransitionType.cupertino,
            );
          },
        ),
        RaisedButton(
          child: Text("cupertino"),
          onPressed: () {
            Application.router.navigateTo(
              context,
              TestRouter.ROUTER_SECOND_TEST + "?title=cupertinoFullScreenDialog",
              transition: TransitionType.cupertinoFullScreenDialog,
            );
          },
        ),
        RaisedButton(
          child: Text("cupertino"),
          onPressed: () {
            Application.router.navigateTo(
              context,
              TestRouter.ROUTER_SECOND_TEST + "?title=fadeIn",
              transition: TransitionType.fadeIn,
            );
          },
        ),
        RaisedButton(
          child: Text("cupertino"),
          onPressed: () {
            Application.router.navigateTo(
              context,
              TestRouter.ROUTER_SECOND_TEST + "?title=inFromBottom",
              transition: TransitionType.inFromBottom,
            );
          },
        ),
        RaisedButton(
          child: Text("cupertino"),
          onPressed: () {
            Application.router.navigateTo(
              context,
              TestRouter.ROUTER_SECOND_TEST + "?title=inFromLeft",
              transition: TransitionType.inFromLeft,
            );
          },
        ),
        RaisedButton(
          child: Text("cupertino"),
          onPressed: () {
            Application.router.navigateTo(
              context,
              TestRouter.ROUTER_SECOND_TEST + "?title=cupertino",
              transition: TransitionType.cupertino,
            );
          },
        ),
        RaisedButton(
          child: Text("cupertino"),
          onPressed: () {
            Application.router.navigateTo(
              context,
              TestRouter.ROUTER_SECOND_TEST + "?title=materialFullScreenDialog",
              transition: TransitionType.materialFullScreenDialog,
            );
          },
        ),
        RaisedButton(
          child: Text("cupertino"),
          onPressed: () {
            Application.router.navigateTo(
              context,
              TestRouter.ROUTER_SECOND_TEST + "?title=native",
              transition: TransitionType.native,
            );
          },
        ),
        RaisedButton(
          child: Text("cupertino"),
          onPressed: () {
            Application.router.navigateTo(
              context,
              TestRouter.ROUTER_SECOND_TEST + "?title=nativeModal",
              transition: TransitionType.nativeModal,
            );
          },
        ),
      ],
    );
  }

  Widget _my(){
    return Wrap(
      spacing: 10,
      children: <Widget>[
        RaisedButton(
          child: Text("cupertino"),
          onPressed: () {
            Application.router.navigateTo(
              context,
              TestRouter.ROUTER_SECOND_TEST + "?title=RippleRouteBuilder",
              transition: TransitionType.custom,
              transitionBuilder: RippleRouteBuilder.transitionBuilder,
            );
          },
        ),
      ],
    );
  }
}

class RouterSecondTest extends StatelessWidget {
  final String title;

  const RouterSecondTest({Key key, this.title}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(title ?? ""),
        backgroundColor: Colors.black,
      ),
      backgroundColor: Colors.black,
      body: Center(
        child: Text(
            "当前的路由效果是: $title",
          style: SFunCommon.fontStyle(
            Colors.white,
            fontSize: 50,
          ),
        ),
      ),
    );
  }
}
